$ () ->
	$(".create_btn").click (e) ->
		param =
			weight: $("#weight").val()

		$.post "/api/weight/create", param, (res) ->
			if res.status.errCode is 0
				alert "添加成功"
			else
				alert res.status.message

	countBmi = () ->
		height = $("#height").val()
		weight = $("#weight").val()
		tempHeight=height / 100
		temp = tempHeight * tempHeight
		temp = (weight / temp).toFixed(1)
		$("#bmi").val(temp)

	$("#weight").bind 'input propertychange',(e) ->
		countBmi()